from threading import Thread
from tkinter import Tk, Menu
from pynput import keyboard
from About import openAbout
from App import RenderContent
from Config import title

win = Tk()
win.title(title)
menubar = Menu(win)
win.config(menu=menubar)

menubar.add_cascade(label='关于', underline=3, command=openAbout)

app = RenderContent(win)

# 设置快捷键


def setHotKeypass(key):
    if key == keyboard.Key.f7:
        app.start()
    elif key == keyboard.Key.f8:
        app.stop()
        print(app.get_mode(), '已停止')

# 监听键盘


def watchKeyBoard():
    with keyboard.Listener(on_press=setHotKeypass) as listener:
        listener.join()


t = Thread(target=watchKeyBoard)
t.setDaemon(True)
t.start()

# 进入消息循环
win.mainloop()
